/**
 * 
 */
package com.mc.hutool;

import java.io.File;

import com.mc.parameter.Parameter;

import cn.hutool.core.io.FileUtil;
import cn.hutool.core.io.StreamProgress;
import cn.hutool.core.lang.Console;
import cn.hutool.http.HttpUtil;

/**
 * 文件下载
 * 云点播 VOD
 * 
 * @author w.weizhen
 *
 */
public class HttpUtilTest {
	public static final String user_dir = System.getProperty("user.dir") + File.separator;
	
	public static final String data_path = user_dir + "data" + File.separator;
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		downloadFile();
	}
	
	private static void downloadFile()
	{
		String url = "http://192.168.12.170:10221/d0d429035915cf3697b33d4e58111e59.jpeg";
//		long size = HttpUtil.downloadFile(url, FileUtil.file("D:\\hynetic\\file\\tmp\\"));
		
//		HttpUtil.downloadFile(url, FileUtil.file("D:/hynetic/file/tmp/"));
		
		File file = FileUtil.file(url);
		System.out.println(file.exists());
		System.out.println(file.isFile());
		
		HttpUtil.downloadFile(url, FileUtil.file("D:/hynetic/file/tmp/", file.getName()));
		
		
		
	}
	
//	private static void downloadFile()
//	{
//		String url = "https://1321690287.vod-qcloud.com/b7be4f29vodcq1321690287/b07e6d153270835011419162137/f0.mp4";
//		String file_path = Parameter.data_path + "hutool" + File.separator + "20231025T094329Z.mp4";
////		//将文件下载后保存在E盘，返回结果为下载文件大小
////		long size = HttpUtil.downloadFile(url, FileUtil.file("e:/"));
////		System.out.println("Download size: " + size);
//		
//		//带进度显示的文件下载
//		HttpUtil.downloadFile(url, FileUtil.file(file_path), new StreamProgress(){
//			
//			@Override
//			public void start() {
//				Console.log("开始下载");
//			}
//			
//			@Override
//			public void progress(long total, long progressSize) {
//				Console.log("共有:{},已下载：{}", FileUtil.readableFileSize(total), FileUtil.readableFileSize(progressSize));
//			}
//			
//			@Override
//			public void finish() {
//				Console.log("下载完成！");
//			}
//		});
//	}
	
}